﻿<Window x:Class="Adan.Client.Dialogs.HotkeysEditDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="Hot keys" 
        ResizeMode="NoResize" 
        ShowInTaskbar="False" 
        WindowStartupLocation="CenterOwner" 
        WindowStyle="ToolWindow" 
        Width="450"
        Height="400" 
        Style="{StaticResource DefaultWindowStyle}"
        Name="HotkeysEditorWindow">
    <Grid  Margin="3">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ItemsControl ItemsSource="{Binding Path=Groups}"  Grid.Row="0"  Margin="0,0,0,5">
            <ItemsControl.Template>
                <ControlTemplate>
                    <ScrollViewer x:Name="ScrollViewer">
                        <ItemsPresenter />
                    </ScrollViewer>
                </ControlTemplate>
            </ItemsControl.Template>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Expander Header="{Binding Path=Name}" HorizontalAlignment="Stretch" IsExpanded="True">
                        <ListBox ItemsSource="{Binding Hotkeys}" BorderBrush="Transparent" Padding="10,0,0,0" HorizontalAlignment="Stretch" SelectedValue="{Binding Path=DataContext.SelectedHotkey, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <ListBox.Resources>
                                <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
                                    <EventSetter Event="MouseDoubleClick" Handler="HandleItemDoubleClick"/>
                                </Style>
                            </ListBox.Resources>
                            <ItemsControl.Template>
                                <ControlTemplate>
                                    <ItemsPresenter />
                                </ControlTemplate>
                            </ItemsControl.Template>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition  Width="100"/>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Text="{Binding Path=HotkeyDescription}" Grid.Column="0" TextTrimming="CharacterEllipsis" />
                                        <TextBlock Margin="15,0,0,0"  Text="{Binding Path=ActionsViewModel.ActionsDescription}" Grid.Column="1" TextTrimming="CharacterEllipsis" />
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Expander>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="1">
            <Button HorizontalAlignment="Left" MinWidth="50" Command="{Binding Path=AddHotkeyCommand}" CommandParameter="{Binding ElementName=HotkeysEditorWindow, Path=.}">Add</Button>
            <Button HorizontalAlignment="Left" Margin="5,0,0,0" MinWidth="50"  Command="{Binding Path=EditHotkeyCommand}"  CommandParameter="{Binding ElementName=HotkeysEditorWindow, Path=.}">Edit</Button>
            <Button HorizontalAlignment="Left" Margin="5,0,0,0" MinWidth="50"  Command="{Binding Path=DeleteHotkeyCommand}">Delete</Button>
        </StackPanel>
        <Button IsCancel="True" Click="HandleCloseClick" HorizontalAlignment="Right" Grid.Row="1" MinWidth="50">Close</Button>
    </Grid>
</Window>
